from product.goods import goods
import threading
import time
from pymongo import MongoClient
from product.mongodb import mongodb
from product.reviews import reviews


goods = goods.goods()
#爬取隐形眼镜数据
data = [
    {'name':'隐形眼镜',"typeId":1},
    {'name':'避孕套',"typeId":2},
    {'name':'美瞳',"typeId":3},
    {'name':'玻尿酸',"typeId":4}
]
startTime = time.time()
for key in data:
    for index in range(1, 5):
        t1 = threading.Thread(target=goods.selectByQuery, args=(key['name'], index, 50,key['typeId'],))
        t1.setDaemon(True)
        t1.start()
    t1.join()
endTime = time.time()
print('商品数据爬取已完成，用时[{0}]'.format(endTime-startTime))